package com.wuye.rcgl.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.wuye.common.annotation.Log;
import com.wuye.common.core.controller.BaseController;
import com.wuye.common.core.domain.AjaxResult;
import com.wuye.common.enums.BusinessType;
import com.wuye.rcgl.domain.WyRepair;
import com.wuye.rcgl.service.IWyRepairService;
import com.wuye.common.utils.poi.ExcelUtil;
import com.wuye.common.core.page.TableDataInfo;

/**
 * 报修处理Controller
 * 
 * @author wpc
 * @date 2024-11-22
 */
@RestController
@RequestMapping("/rcgl/repair")
public class WyRepairController extends BaseController
{
    @Autowired
    private IWyRepairService wyRepairService;

    /**
     * 查询报修处理列表
     */
    @PreAuthorize("@ss.hasPermi('rcgl:repair:list')")
    @GetMapping("/list")
    public TableDataInfo list(WyRepair wyRepair)
    {
        startPage();
        List<WyRepair> list = wyRepairService.selectWyRepairList(wyRepair);
        return getDataTable(list);
    }

    /**
     * 导出报修处理列表
     */
    @PreAuthorize("@ss.hasPermi('rcgl:repair:export')")
    @Log(title = "报修处理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WyRepair wyRepair)
    {
        List<WyRepair> list = wyRepairService.selectWyRepairList(wyRepair);
        ExcelUtil<WyRepair> util = new ExcelUtil<WyRepair>(WyRepair.class);
        util.exportExcel(response, list, "报修处理数据");
    }

    /**
     * 获取报修处理详细信息
     */
    @PreAuthorize("@ss.hasPermi('rcgl:repair:query')")
    @GetMapping(value = "/{repairId}")
    public AjaxResult getInfo(@PathVariable("repairId") Long repairId)
    {
        return success(wyRepairService.selectWyRepairByRepairId(repairId));
    }

    /**
     * 新增报修处理
     */
    @PreAuthorize("@ss.hasPermi('rcgl:repair:add')")
    @Log(title = "报修处理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WyRepair wyRepair)
    {
        return toAjax(wyRepairService.insertWyRepair(wyRepair));
    }

    /**
     * 修改报修处理
     */
    @PreAuthorize("@ss.hasPermi('rcgl:repair:edit')")
    @Log(title = "报修处理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WyRepair wyRepair)
    {
        return toAjax(wyRepairService.updateWyRepair(wyRepair));
    }

    /**
     * 删除报修处理
     */
    @PreAuthorize("@ss.hasPermi('rcgl:repair:remove')")
    @Log(title = "报修处理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{repairIds}")
    public AjaxResult remove(@PathVariable Long[] repairIds)
    {
        return toAjax(wyRepairService.deleteWyRepairByRepairIds(repairIds));
    }

    /**
     * 维修修改处理
     */
    @PreAuthorize("@ss.hasPermi('rcgl:repair:edit')")
    @Log(title = "维修修改处理", businessType = BusinessType.UPDATE)
    @PutMapping("/edit")
    public AjaxResult editRepair(@RequestBody WyRepair wyRepair)
    {
        return toAjax(wyRepairService.editRepair(wyRepair));
    }
}
